<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache"/>
<meta HTTP-EQUIV="Expires" CONTENT="-1"/>
<link rel="shortcut icon" href="images/favicon.png"/>
<link rel="icon" href="images/favicon.png"/>
<title>软件中心 - NatAPP内网穿透</title>
<link rel="stylesheet" type="text/css" href="index_style.css"/>
<link rel="stylesheet" type="text/css" href="form_style.css"/>
<link rel="stylesheet" type="text/css" href="usp_style.css"/>
<link rel="stylesheet" type="text/css" href="css/element.css">
<link rel="stylesheet" type="text/css" href="/device-map/device-map.css">
<link rel="stylesheet" type="text/css" href="/res/softcenter.css">
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/state.js"></script>
<script type="text/javascript" src="/popup.js"></script>
<script type="text/javascript" src="/validator.js"></script>
<script type="text/javascript" src="/general.js"></script>
<script type="text/javascript" src="/switcherplugin/jquery.iphone-switch.js"></script>
<script type="text/javascript" src="/client_function.js"></script>
<script type="text/javascript" src="/res/softcenter.js"></script>
<style>
.help_btn {
    border: 1px solid #222;
    background: linear-gradient(to bottom, #003333  0%, #000000 100%); /* W3C */
    font-size:10pt;
    color: #fff;
    padding: 5px 5px;
    border-radius: 5px 5px 5px 5px;
    width:14%;
}
.help_btn:hover {
    border: 1px solid #222;
    background: linear-gradient(to bottom, #27c9c9  0%, #279fd9 100%); /* W3C */
    font-size:10pt;
    color: #fff;
    padding: 5px 5px;
    border-radius: 5px 5px 5px 5px;
    width:14%;
}
input[type=button]:focus {
    outline: none;
}
</style>
<script>
var noChange_status=0;
var _responseLen;
function init(){
    show_menu(menu_hook);
    get_dbus_data();
    //get_run_status();
}
var db_natapp = {};
function get_dbus_data() {
    $.ajax({
        type: "GET",
        url: "/_api/natapp",
        dataType: "json",
        async: false,
        success: function(data) {
            db_natapp = data.result[0];
            console.log(db_natapp);
            conf_to_obj();
        }
    });
}
function conf_to_obj() {
    $('#natapp_enable').prop('checked', db_natapp["natapp_enable"] ? true : false);
    $('#natapp_authtoken').val(db_natapp["natapp_authtoken"]);
    $('#natapp_clienttoken').val(db_natapp["natapp_clienttoken"]);
    $('#natapp_status').html(db_natapp["natapp_last_status"]);
    $('#natapp_time').html(db_natapp["natapp_last_act"]);
}
function onSubmitCtrl(){
    showLoading(3);
    refreshpage(3);

    db_natapp['natapp_enable'] = $("#natapp_enable").prop('checked') ? 1 : 0;
    db_natapp["natapp_authtoken"] = $('#natapp_authtoken').val();
    db_natapp["natapp_clienttoken"] = $('#natapp_token').val();

    var id = parseInt(Math.random() * 100000000);
    var postData = {"id": id, "method": "natapp_config.sh", "params":[1], "fields": db_natapp};
    $.ajax({
        url: "/_api/",
        cache: false,
        type: "POST",
        dataType: "json",
        data: JSON.stringify(postData),
        success : function() {
            //refreshpage(0);
        }
    });
}

function reload_Soft_Center(){
    location.href = "/Module_Softcenter.asp";
}

function menu_hook() {
    tabtitle[tabtitle.length -1] = new Array("", "natapp 内网穿透", "__INHERIT__");
    tablink[tablink.length -1] = new Array("", "Module_natapp.asp", "NULL");
}
</script>
</head>
<body onload="init();">
    <div id="TopBanner"></div>
    <div id="Loading" class="popup_bg"></div>
    <div id="LoadingBar" class="popup_bar_bg">
        <table cellpadding="5" cellspacing="0" id="loadingBarBlock" class="loadingBarBlock" align="center">
            <tr>
                <td height="100">
                    <div id="loading_block3" style="margin:10px auto;width:85%; font-size:12pt;">数据提交中，请稍候...</div>
                </td>
            </tr>
        </table>
    </div>
    <table class="content" align="center" cellpadding="0" cellspacing="0">
        <tr>
            <td width="17">&nbsp;</td>
            <td valign="top" width="202">
                <div id="mainMenu"></div>
                <div id="subMenu"></div>
            </td>
            <td valign="top"><div id="tabMenu" class="submenuBlock"></div>
                <table width="98%" border="0" align="left" cellpadding="0" cellspacing="0">
                    <tr>
                        <td align="left" valign="top">
                            <table width="760px" border="0" cellpadding="5" cellspacing="0" bordercolor="#6b8fa3" class="FormTitle" id="FormTitle" style="border: 0px solid transparent;">
                                <tr>
                                    <td bgcolor="#4D595D" colspan="3" valign="top" style="border-radius: 8px"><div>&nbsp;</div>
                                        <div class="formfonttitle">软件中心 - NatAPP内网穿透</div>
                                        <div style="float:right; width:15px; height:25px;margin-top:-20px">
                                            <img id="return_btn" onclick="reload_Soft_Center();" align="right" style="cursor:pointer;position:absolute;margin-left:-30px;margin-top:-25px;" title="返回软件中心" src="/images/backprev.png" onMouseOver="this.src='/images/backprevclick.png'" onMouseOut="this.src='/images/backprev.png'"></img>
                                        </div>
                                        <div style="margin-left:5px;margin-top:10px;margin-bottom:10px"><img src="/images/New_ui/export/line_export.png"></div>
                                        <div class="SimpleNote">
                                            <li>NatAPP是基于ngrokc的内网穿透工具</em></li>
                                        </div>
                                        <table width="100%" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#6b8fa3" class="FormTable">
                                            <thead>
                                                <tr>
                                                    <td colspan="2">natapp - 高级设置</td>
                                                </tr>
                                            </thead>
                                            <tr id="switch_tr">
                                                <th>
                                                    <label>开关</label>
                                                </th>
                                                <td colspan="2">
                                                    <div clanatapp="switch_field" style="display:table-cell;float: left;">
                                                        <label for="natapp_enable">
                                                            <input id="natapp_enable" class="switch" type="checkbox" style="display: none;">
                                                            <div class="switch_container" >
                                                                <div class="switch_bar"></div>
                                                                <div class="switch_circle transition_style">
                                                                    <div></div>
                                                                </div>
                                                            </div>
                                                        </label>
                                                    </div>
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>运行状态</th>
                                                <td><span id="natapp_status">获取中...</span></td>
                                            </tr>
                                            <tr>
                                                <th>最近运行时间</th>
                                                <td><span id="natapp_time">暂无运行时间</span></td>
                                            </tr>
                                            <tr>
                                                <th>普通隧道Token</th>
                                                <td>
                                                    <input style="width:300px;background-image: none;background-color: #576d73;border:1px solid gray" type="text" class="input_ss_table" id="natapp_authtoken" name="natapp_authtoken" maxlength="100" value=""> （authtoken）
                                                </td>
                                            </tr>
                                            <tr>
                                                <th>聚合隧道Token</th>
                                                <td>
                                                    <input style="width:300px;background-image: none;background-color: #576d73;border:1px solid gray" type="text" class="input_ss_table" id="natapp_clienttoken" name="natapp_clienttoken" maxlength="100" value="">（clienttoken）
                                                </td>
                                            </tr>
                                            <tr id="rule_update_switch">
                                                <th>插件帮助</th>
                                                <td>
                                                    <a type="button" class="help_btn" style="cursor:pointer" target="_blank" href="https://natapp.cn/" target="_blank">natapp官网</a>
                                                    <a type="button" class="help_btn" style="cursor:pointer" target="_blank" href="https://gitee.com/duxcms/merlin-natapp">插件反馈</a>
                                                </td>
                                            </tr>
                                        </table>

                                        <div id="warning" style="font-size:14px;margin:20px auto;"></div>
                                        <div class="apply_gen">
                                            <input class="button_gen" id="cmdBtn" onClick="onSubmitCtrl(this, ' Refresh ')" type="button" value="提交" />
                                        </div>
                                        <div style="margin-left:5px;margin-top:10px;margin-bottom:10px"><img src="/images/New_ui/export/line_export.png"></div>
                                            <h2>使用说明：</h2>
                                            <p>普通隧道与聚合隧道二选一，聚合隧道会优先于普通隧道，暂不支持免费隧道，因免费隧道暂时无法返回随机域名，请直接购买收费隧道绑定域名即可，<a href="https://natapp.cn/" target="_blank"><font color="red">点击申请</font></a>，购买隧道时输入优惠码<font color="red">EE29B1CE</font>可以九折优惠。</p>
                                            <div style="margin-left:5px;margin-top:10px;margin-bottom:10px"><img src="/images/New_ui/export/line_export.png"></div>
                                                                                <div id="NoteBox">
                                                                                <h2>更新日志：</h2>
                                                                                <p>1.1.0</p>
                                                                                <p>   - change 升级到新平台支持AC86U等</p>
                                                                                <p>1.0.1</p>
                                                                                <p>   - fix 修正变量不正确问题</p>
                                                                                <p>   - fix 修正新版本参数问题</p>
                                                                                <p>   - change 优化状态判断逻辑</p>
                                                                                <p>1.0.0</p>
                                                                                <p>   - change  增加联网重启wan自动重启natapp</p>
                                                                                <p>   - change  增加运行状态信息</p>
                                                                                <p>   - change  更新最新版本客户端</p>
                                                                                <p>0.1</p>
                                                                                <p>   - change  初步支持NATAPP内网穿透</p>
                                                                                </div>

                                        <div style="margin-left:5px;margin-top:10px;margin-bottom:10px"><img src="/images/New_ui/export/line_export.png"></div>
                                        <div class="KoolshareBottom">
                                            <br/>
                                            论坛技术支持： <a href="http://www.koolshare.cn" target="_blank"> <i><u>www.koolshare.cn</u></i> </a> <br/>
                                            Plugins by： <i>Mr.L</i></i>
                                        </div>

                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
            <td width="10" align="center" valign="top"></td>
        </tr>
    </table>
<div id="footer"></div>
</body>
</html>